package cn.ml.duoXianCheng.demos;

import java.util.ArrayList;
import java.util.List;

public class UnsafeList {
    private static int count = 1;

    public static void main(String[] args) {


        List<String> list = new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            new Thread(()->{
                list.add(Thread.currentThread().getName());
                System.out.println("第"+ count +"条"+Thread.currentThread().getName()+"。。。");
                count ++;
            }).start();
        }

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(list.size());

    }
}
